<?php 

/* draws a calendar */

	/* days and weeks vars now ... */
	$running_day = date('w',mktime(0,0,0,$month,1,$year));
	$days_in_month = date('t',mktime(0,0,0,$month,1,$year));
	$days_in_this_week = 1;
	$day_counter = 0;
	$dates_array = array();	
		
	$j = $running_day;
	
	/* table headings */
	$headings = array('S','M','Tu','W','Th','F','Sa');	
	
	/* draw table */?>
	<table cellpadding="0" cellspacing="0" class="calendar">

	<tr>
	<th class="calendar-day-head">
		User
	</th>
	
	
	
	<?php
	for ($i= 1; $i<=$days_in_month;$i++):
	
		if($headings[$j]=='Sa'):?>

			<th class="calendar-day-np">
		
					<?php
					echo $headings[$j].'<br>'.$i;
					
					if($j==sizeof($headings)-1)
						$j=0;
					else
						$j++;
					?>
			</th>			
		<?php
		else:?>
		
			<th class="calendar-day-head">
		
					<?php
					echo $headings[$j].'<br>'.$i;
					
					if($j==sizeof($headings)-1)
						$j=0;
					else
						$j++;
					?>
			</th>		
		<?php
		endif;?>
	<?php 
	endfor;
	
	echo '</tr>';
	
	foreach ($this->schedulesData as $scheduleRow):?>
		
		<tr>
			<?php
			for ($i=0;$i<sizeof($scheduleRow)-1;$i++):
				$enableClick=0;
				if($i>0)
					$enableClick=1;
			?>
				<td class="calendar-day" 
					<?php 
						if($enableClick) 
							echo 'onclick="openTopViewer(\''.$scheduleRow[0].'\',\''.$year.'\',\''.$month.'\',\''.$i.'\');"';
					?>
					>
					<?php
					if ($scheduleRow[$i]=='empty')
						echo "-";
					else
						echo $scheduleRow[$i];
					?>
				</td>
			
			<?php
			endfor;
			?>
		</tr>
	<?php 
	endforeach;
?>